<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Create blob, copy file in it, and close it</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.ibase-blob-import" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ibase_blob_import</h1>
  <p class="verinfo">(PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">ibase_blob_import</span> &mdash; <span class="dc-title">Create blob, copy file in it, and close it</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.ibase-blob-import-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>ibase_blob_import</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$link_identifier</code></span>
   , <span class="methodparam"><span class="type">resource</span> <code class="parameter">$file_handle</code></span>
   ) : <span class="type">string</span></div>

  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>ibase_blob_import</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$file_handle</code></span>
   ) : <span class="type">string</span></div>

  <p class="para rdfs-comment">
   This function creates a BLOB, reads an entire file into it, closes it and
   returns the assigned BLOB id.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.ibase-blob-import-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">link_identifier</code></dt>

     <dd>

      <p class="para">
       An InterBase link identifier. If omitted, the last opened link is
       assumed.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">file_handle</code></dt>

     <dd>

      <p class="para">
       The file handle is a handle returned by <span class="function"><a href="fopen.html" class="function">fopen()</a></span>.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.ibase-blob-import-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the BLOB id on success, or <strong><code>FALSE</code></strong> on error.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.ibase-blob-import-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-1195">
    <p><strong>Example #1 <span class="function"><strong>ibase_blob_import()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$dbh&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ibase_connect</span><span style="color: #007700">(</span><span style="color: #0000BB">$host</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$username</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$password</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$filename&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'/tmp/bar'</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$fd&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'r'</span><span style="color: #007700">);<br />if&nbsp;(</span><span style="color: #0000BB">$fd</span><span style="color: #007700">)&nbsp;{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$blob&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ibase_blob_import</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbh</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$fd</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$fd</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!</span><span style="color: #0000BB">is_string</span><span style="color: #007700">(</span><span style="color: #0000BB">$blob</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;import&nbsp;failed<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$query&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"INSERT&nbsp;INTO&nbsp;foo&nbsp;(name,&nbsp;data)&nbsp;VALUES&nbsp;('</span><span style="color: #0000BB">$filename</span><span style="color: #DD0000">',&nbsp;?)"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$prepared&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ibase_prepare</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbh</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$query</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!</span><span style="color: #0000BB">ibase_execute</span><span style="color: #007700">(</span><span style="color: #0000BB">$prepared</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$blob</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;record&nbsp;insertion&nbsp;failed<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">}<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;unable&nbsp;to&nbsp;open&nbsp;the&nbsp;data&nbsp;file<br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.ibase-blob-import-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="ibase_blob_add.html" class="function" rel="rdfs-seeAlso">ibase_blob_add()</a> - Add data into a newly created blob</span></li>
    <li class="member"><span class="function"><a href="ibase_blob_cancel.html" class="function" rel="rdfs-seeAlso">ibase_blob_cancel()</a> - Cancel creating blob</span></li>
    <li class="member"><span class="function"><a href="ibase_blob_close.html" class="function" rel="rdfs-seeAlso">ibase_blob_close()</a> - Close blob</span></li>
    <li class="member"><span class="function"><a href="ibase_blob_create.html" class="function" rel="rdfs-seeAlso">ibase_blob_create()</a> - Create a new blob for adding data</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>